﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;


namespace MKIB3Game
{
    public class Figure
    {
        private int points;
        private int id;
        private FigureTypeEnum type;
        private bool busy;
        private String desc;
        private int x;
        private int y;
        private List<Point> moveTracker;
        public List<Point> lastPaintedMove = new List<Point>();

        public Figure(int points, int id, FigureTypeEnum type, bool busy, String desc, int x, int y)
        {
            moveTracker = new List<Point>();

            setPoints(points);
            setID(id);
            setType(type);
            setBusy(busy);
            setDesc(desc);
            setX(x);
            setY(y);


        }
        public List<Point> getMoveTracker()
        {
            return this.moveTracker;
        }

        public void setY(int y)
        {
            Point p = new Point(this.x, this.y);
            if(this.moveTracker.Count >0 && !p.Equals(this.moveTracker[this.moveTracker.Count-1]))
                moveTracker.Add(p);
            this.y = y;
        }

        public void setX(int x)
        {
            Point p = new Point(this.x, this.y);
            if (this.moveTracker.Count > 0 && !p.Equals(this.moveTracker[this.moveTracker.Count - 1]))
                moveTracker.Add(p);
            this.x = x;
        }

        public void setDesc(string desc)
        {
            this.desc = desc;
        }

        public void setBusy(bool busy)
        {
            this.busy = busy;
        }

        public void setType(FigureTypeEnum type)
        {
            this.type = type;
        }

        public void setID(int id)
        {
            this.id = id;
        }

        public void setPoints(int points)
        {
            this.points = points;
        }

        public int getY()
        {
            return y;
        }

        public int getX()
        {
            return x;
        }

        public String getDesc()
        {
            return desc;
        }

        public bool getBusy()
        {
            return busy;
        }

        public FigureTypeEnum getType()
        {
            return type;
        }

        public int getID()
        {
            return id;
        }

        public int getPoints()
        {
            return points;
        }
        public void updateAttributesTo(Figure other)
        {
            this.setPoints(other.getPoints());
           // this.getID(other.getID());
            this.setType(other.getType());
            this.setBusy(other.getBusy());
            this.setDesc(other.getDesc());
            this.setX(other.getX());
            this.setY(other.getY());
            
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        public override bool Equals(object obj)
        {
            if (obj is Figure)
            {
                Figure f = (Figure)obj;
                if (this.getID() == f.getID())
                {
                    return true;
                }
            }
            return false;
        }
    }
}
